package com.imooc;


import com.imooc.Interceptor.PassportInterceptor;

import com.imooc.Interceptor.UserTokenInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Bean
    public PassportInterceptor getPassportInterceptor(){
        return  new  PassportInterceptor();
    }

    @Bean
    public UserTokenInterceptor getUserTokenInterceptor(){
        return  new  UserTokenInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(getPassportInterceptor()).addPathPatterns("/passport/getSMSCode");

        registry.addInterceptor(getUserTokenInterceptor()).addPathPatterns("/userInfo/modifyUserInfo","/userInfo/modifyImage");
    }

}
